import { createI18n } from "vue-i18n";
import zh from "./locales/zh.json";
import en from "./locales/en.json";

let language: any = "zh";

export default defineNuxtPlugin(({ vueApp }) => {
  if (process.client && localStorage.getItem("language")) {
    language = localStorage.getItem("language");
  }
  const i18n = createI18n({
    legacy: false,
    globalInjection: true,
    locale: language,
    messages: {
      zh,
      en,
    },
  });

  vueApp.use(i18n);
});
